﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Xml.Linq;

namespace BaseTypesLib.Model.Backgrounds
{
    public class TransparentColorBackground:SolidColorBackground
    {
        private byte alpha;
        public byte Alpha 
        {
            get { return alpha; }
            set
            {
                if (alpha != value)
                {
                    alpha = value;
                    OnPropertyChanged("Alpha");
                }
            }
        }
        public override string ToString()
        {
            return "Transparent";
        }
        public override XElement GetXml()
        {
            XElement elem = base.GetXml();
            elem.SetAttributeValue("Alpha", Alpha);
            return elem;
        }
        protected override void FromXmlElement(XElement elem)
        {
            base.FromXmlElement(elem);
            var c = elem.Attributes("Alpha").FirstOrDefault();
            if (c != null)
                Alpha = (byte)(int)c;

        }
    }
}
